---@class GT.road 路径
---@field road Road 路径
GT.road = class()

---@class road_data 路径
---@field road Road 路径

---@param data road_data
function GT.road:ctor(data)
    self.road = data.road
end

--- 获取某路径循环n次后的路径
---@param n Int32 循环次数
---@return GT.road
function GT.road:get_road_point_list_loop(n)
    ---@type road_data
    local data = {
        road = game_api.get_road_point_list_loop(self.road, n)
    }

    return new(GT.road, data)
end

--- 获取两路径拼接后的路径
---@param pl1 GT.road 原始路径
---@param pl2 GT.road 原始路径
---@return GT.road
function GT.road.get_road_point_list_join(pl1, pl2)
    ---@type road_data
    local data = {
        road = game_api.get_road_point_list_join(pl1.road, pl2.road)
    }

    return new(GT.road, data)
end

--- 获取某路径反转后的路径
---@return Road
function GT.road:get_road_point_list_inversion(point_list)
    ---@type road_data
    local data = {
        road = game_api.get_road_point_list_inversion(self.road)
    }

    return new(GT.road, data)
end

--- 获取路径中点的数量
---@return Int32
function GT.road:get_road_point_num()
    return game_api.get_road_point_num(self.road)
end

--- 移除路径点
---@param road_point_list Road 路径
---@param num Int32 序号
function GT.road:del(num)
    game_api.get_road_point_num(self.road, num)
end

--- 获取某点的最近路径
---@param point GT.point 位置
---@return GT.road
function GT.road:get_nearest_road_point_list_by_pos(point)
    ---@type road_data
    local data = {
        road = game_api.get_nearest_road_point_list_by_pos(point.point)
    }

    return new(GT.road, data)
end

--- 获取某路径偏移后的路径
---@param offset Fixed 偏移距离
---@return GT.road
function GT.road:get_road_point_list_by_offset(offset)
    ---@type road_data
    local data = {
        road = game_api.get_road_point_list_by_offset(self.road, offset)
    }

    return new(GT.road, data)
end

--- 在某点创建一条路径
---@param point GT.point 点
---@return GT.road
function GT.road.create_road_point_list(point)
    ---@type road_data
    local data = {
        road = game_api.create_road_point_list(point.point)
    }

    return new(GT.road, data)
end

--- 移除路径
function GT.road:remove_road_point_list()
    game_api.remove_road_point_list(self.road)
end

--- 给路径添加点
---@param num Int32 序号
---@param point GT.point 点
function GT.road:add_road_point(num, point)
    game_api.add_road_point(self.road, num, point.point)
end

--- 通过资源id返回路径
---@param res_id Int32 资源ID
---@return GT.road
function GT.road.get_road_point_list_by_res_id(res_id)
    ---@type road_data
    local data = {
        road = game_api.get_road_point_list_by_res_id(res_id)
    }

    return new(GT.road, data)
end

--- 路径是否存在
---@param point_list GT.road 路径
---@return Bool
function GT.road.point_list_is_exist(point_list)
    return game_api.point_list_is_exist(point_list.road)
end

--- 给路径添加tag
---@param tag Str tag
function GT.road:add_road_tag(tag)
    game_api.add_road_tag(self.road, tag)
end

--- 给路径移除tag
---@param tag Str tag
function GT.road:remove_road_tag(tag)
    return game_api.add_road_tag(self.road, tag)
end

--- 路径是否拥有某tags
---@param tag Str tag
---@return Bool
function GT.road:if_road_has_tag(tag)
    return game_api.add_road_tag(self.road, tag)
end

--- 根据tag获取对应的路径
---@param tag Str tag
---@return Road
function GT.road.get_roads_by_tag(tag)
    ---@type road_data
    local data = {
        road = game_api.get_roads_by_tag(tag)
    }

    return new(GT.road, data)
end
